package com.bwie.controller;

import com.bwie.mapper.TbOrderMapper;
import com.bwie.pojo.TbOrder;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 牛毅
 * @version 1.0
 * @date 2025/7/23
 * @description TODO
 */
@RestController
@RequestMapping("/prod/order")
public class OrderController {
    @Autowired
    TbOrderService tbOrderService;

    /**
     * @description: 查询订单列表
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/23 17:05
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo){
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * @description: 批量删除订单
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/23 19:44
     */
    @PostMapping("/deleteBatchByOrderId")
    public  R deleteBatchByOrder(@RequestBody List<TbOrder> orderList){
        return tbOrderService.deleteBatchByOrder(orderList);
    }

    /**
     * @description: 根据缓存导出
     * @param: userId
     * @return: void
     * @author 牛毅
     * @date: 2025/7/23 19:51
     */
    @GetMapping("/uploadExout/{userId}")
    public void uploadExout(@PathVariable("userId")Integer userId){
        tbOrderService.uploadExout(userId);
    }

    /**
     * @description: 获取商品详情列表
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/23 19:55
     */
    @PostMapping("/getProdInfo")
    public R getProdInfo(){
        return tbOrderService.getProdInfo();
    }

    /**
     * @description: 添加订单
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/23 19:58
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody  List<TbProdInfo> infoList){
        return tbOrderService.addOrder(infoList);
    }
}
